<template>
  <div class="product-list">
    <h2 class="section-title">热门宠物商品</h2>
    <div class="products">
      <div class="product-card" v-for="product in products" :key="product.id">
        <div class="product-image-placeholder">
          {{ product.placeholder }}
        </div>
        <h3 class="product-name">{{ product.name }}</h3>
        <p class="product-price">¥{{ product.price }}</p>
        <div class="product-tags">
          <span v-for="tag in product.tags" :key="tag" class="tag">{{
            tag
          }}</span>
        </div>
        <button class="add-to-cart">加入购物车</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "ProductList",
  data() {
    return {
      products: [
        {
          id: 1,
          name: "皇家狗粮 成犬专用",
          price: 189,
          placeholder: "🐶",
          tags: ["热销", "进口"],
        },
        {
          id: 2,
          name: "猫咪自动饮水机",
          price: 159,
          placeholder: "🐱",
          tags: ["智能"],
        },
        {
          id: 3,
          name: "宠物外出便携包",
          price: 89,
          placeholder: "👜",
          tags: ["新品"],
        },
        {
          id: 4,
          name: "狗狗磨牙玩具",
          price: 35,
          placeholder: "🦴",
          tags: ["特惠"],
        },
        {
          id: 5,
          name: "猫砂盆全封闭式",
          price: 129,
          placeholder: "🚽",
          tags: ["除臭"],
        },
        {
          id: 6,
          name: "宠物梳毛器",
          price: 45,
          placeholder: "💇",
          tags: ["护理"],
        },
      ],
    };
  },
};
</script>

<style scoped>
.section-title {
  font-size: 20px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  color: #67c23a;
}
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
.product-card {
  background-color: #fff;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
}
.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.product-image-placeholder {
  height: 150px;
  background-color: #f0f9eb;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 48px;
  border-radius: 6px;
}
.product-name {
  font-size: 16px;
  margin: 0 0 8px 0;
  height: 40px;
  overflow: hidden;
}
.product-price {
  color: #f56c6c;
  font-weight: bold;
  margin: 0 0 10px 0;
}
.product-tags {
  margin-bottom: 10px;
}
.tag {
  display: inline-block;
  padding: 2px 6px;
  background-color: #e1f3d8;
  color: #67c23a;
  border-radius: 4px;
  font-size: 12px;
  margin-right: 5px;
}
.add-to-cart {
  width: 100%;
  padding: 8px;
  background-color: #67c23a;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}
.add-to-cart:hover {
  background-color: #5daf34;
}
</style>
